package edu.kit.aifb.evtcrawl.twitter;

import twitter4j.FilterQuery;
import twitter4j.StatusListener;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;

public class TwitterHandler {
	private FilterQuery filter;
	private String[] keywords;
	TwitterStream twitterStream;
	
	public TwitterHandler(String[] keywords){
		this.keywords = keywords;
	}
	
	public void init(StatusListener listener){
		twitterStream = new TwitterStreamFactory().getInstance();
		twitterStream.addListener(listener);
		
		filter = new FilterQuery();
		filter.track(keywords);
	}
	
	public void startStreaming(){
		twitterStream.filter(filter);
	}
	
	public void stopStreaming(){
		twitterStream.shutdown();
	}
	
}
